import logging
import time

logger = logging.getLogger('bigdata.decorate.time_util')

"""
定义简单的装饰器,用来输出程序运行的所用时间,不带参数
"""
def timer(func):
    def decor(*args):
        start_time = time.time()
        result = func(*args)
        end_time = time.time()
        interval_time = (end_time - start_time) * 1000
        # print("run the func use : ", interval_time)
        logger.info('run_time of {} is {} '.format(func.__name__, interval_time))
        return result
    return decor